<?php session_start(); include('bin/function.php'); ?>
<?php
if (!isset($_SESSION['username']) || empty($_SESSION['username'])) {
	echo "<script type='text/javascript'>location.href='login.php'</script>";
	exit();
}

$file   = "/SmartGrid/config.xml";
$array  = xml_to_array($file);
if ($array['HBConfig']['hb']['@attributes']['enable'] == 'off') {
	$ha_state = 'alone';
}else{
	$ha_state = $array['HBConfig']['hb']['@attributes']['current_state'] ? $array['HBConfig']['hb']['@attributes']['current_state'] : 'alone';
}
$appversion = `/SmartGrid/shell/daemon4 -v | awk '{print $2}'`;
setcookie('appversion',$appversion);
setcookie('hbstate',$ha_state);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>WiseGrid 慧敏应用交付网关</title>
<link href="images/style.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="extjs/resources/css/xtheme-silverCherry.css" /> 
<link rel="stylesheet" type="text/css" href="tasks.css" />
<link rel="stylesheet" type="text/css" href="images/icons.css" />
<style type="text/css">
    #loading-mask{
        position:absolute;
        left:0;
        top:0;
        width:100%;
        height:100%;
        z-index:20000;
        background-color:white;
    }
    #loading{
        position:absolute;
        left:45%;
        top:40%;
        padding:2px;
        z-index:20001;
        height:auto;
    }
    #loading a {
        color:#225588;
    }
    #loading .loading-indicator{
        background:white;
        color:#444;
        font:bold 13px tahoma,arial,helvetica;
        padding:10px;
        margin:0;
        height:auto;
    }
    #loading-msg {
        font: normal 10px arial,tahoma,sans-serif;
    }
</style>
</head>
<body onresize= "homepage_auto_width_hieght();">
<div id="loading-mask"></div>
<div id="loading">
    <div class="loading-indicator"><img src="../images/extanim32.gif" width="32" height="32" style="margin-right:8px;float:left;vertical-align:top;"/>WiseGrid 慧敏应用交付网关<br /><span id="loading-msg">Loading styles and images...</span></div>
</div>
<script type="text/javascript">document.getElementById('loading-msg').innerHTML = 'Loading 核心文件...';</script>

<script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="extjs/ext-all.js"></script>


<script type="text/javascript" src="extjs/src/locale/ext-lang-zh_CN.js"></script>

<script type="text/javascript" src="jsgauge/excanvas.js"></script>
<script type="text/javascript" src="jsgauge/jquery-1.6.min.js"></script>  
   
<script type="text/javascript" src="dygraph/dygraph-dev.js"></script>
<script type="text/javascript" src="extjs/ux/FileUploadField.js"></script>

<script type="text/javascript" src="jsgauge/gauge.js"></script>
 	

 	
<script type="text/javascript" src="js/ipv4field.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/homepage.js"></script>
<script type="text/javascript" src="js/dashboard.js"></script>
<script type="text/javascript" src="js/stats.js"></script>
<script type="text/javascript" src="js/index.js"></script>

<script type="text/javascript">

if(document.all){
	if(navigator.userAgent.indexOf("MSIE 6.0") > 0){
		location.href = 'login.php';
	}
}

function homepage_auto_width_hieght(){
	if(document.getElementById('homepage') != null){
		homepage_click_handler();
	}
}

var timer = setInterval(function() {
	Ext.Ajax.request({
		url: 'bin/network_xml.php?action=gettopdate',
		success: function(response, options) {
			var responsearr = Ext.util.JSON.decode(response.responseText);
			if(responsearr.success==true){
				if(responsearr.hbstate == 'alone')
					hb_state = '单机';
				else if(responsearr.hbstate == 'MASTER'){
					hb_state = '主机';
				}else if(responsearr.hbstate == 'BACKUP'){
					hb_state = '备机'
				}						
				document.getElementById('system_state').innerHTML = hb_state;
				if(document.getElementById('homepage') != null){
					document.getElementById('ha_mode_id').innerHTML = hb_state;
				}
				document.getElementById('system_appversion').innerHTML = responsearr.appversion;
				document.cookie="hbstate=" + responsearr.hbstate;
				document.cookie="appversion=" + responsearr.appversion;
			}
		}
	});
}, 15000);
function initialization(){
	var hideMask = function () {
		Ext.get('loading').remove();
		Ext.fly('loading-mask').fadeOut({
			remove:true
		});
	}
	hideMask.defer(0);

	Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget = 'side';

	Ext.BLANK_IMAGE_URL="../images/s.gif";
}

</script>
	<!-- system-manage start 系统管理   -->
	<ul id="system-manage" class="x-hidden" style="background-color:rgb(241,241,241);">
		<!--<li>
			
			<img src="images/icons/fam/privicons/config_manage.png" />
			<a href="javascript:void(0);" rel="bin/config.php" title="配置管理">配置管理</a>
		</li>-->
		<li>
			<img src="images/icons/fam/privicons/system_manage.gif" />
			<a href="javascript:void(0);" rel="bin/sysadmin.php" title="系统管理">系统管理</a>
		</li>

		<?php
		if ($_COOKIE['role'] == "superadmin") {
		?>
			<li>
			<img src="images/icons/fam/privicons/login_auth.png" />
			<a href="javascript:void(0);" rel="bin/auth.php" title="认证管理">认证管理</a>
			</li>
		<?php
		}
		?>



		<?php
		if ($_COOKIE['role'] == "superadmin") {
		?>
				<li>
				<img src="images/icons/fam/privicons/user_manage.png" />
				<a href="javascript:void(0);" rel="bin/user.php" title="用户管理">用户管理</a>
				</li>
		<?php 
		}
		?>
		<li>
			<img src="images/icons/fam/privicons/ssl_cert.png" />
			<a href="javascript:void(0);" rel="bin/certificate.php" title="SSL证书管理">SSL证书管理</a>
		</li>
		
		<li>
			<img src="images/icons/fam/privicons/ssl_revoke.png" />
			<a href="javascript:void(0);" rel="bin/certtable.php" title="证书吊销列表管理">证书吊销列表管理</a>
		</li>
		 <!-- <li>
			<img src="images/s.gif" class="icon-no-group"/>
			<a href="javascript:void(0);" rel="bin/control.php" title="控制台管理">控制台管理</a>
		</li> --> 
		<?php
		//$funcs = $_COOKIE['funcs'];
		//if ($funcs[1] == "Y" || $funcs[1] == "y") {
		?>
		<li>
			<img src="images/icons/fam/privicons/snmp.png" />
			<a href="javascript:void(0);" rel="bin/snmp.php" title="SNMP配置管理">SNMP配置管理</a>
		</li>
		<?php
		//}
		?>

			<!-- HA-manage start HA管理   -->
		<?php
		//	$funcs = $_COOKIE['funcs'];
		//if ($funcs[0] == "Y" || $funcs[0] == "y") {
		?>
		<li>
			<img src="images/icons/fam/privicons/hb.png" />
			<a href="javascript:void(0);" rel="bin/hb.php" title="双机热备管理">双机热备管理</a>
		</li>
		<?php
		//	}
		?>

	<!-- HA-manage end  -->
	</ul>
	<!-- system-manage end   -->
	
	<!-- network-manage start 网络管理   -->
	<ul id="network-manage" class="x-hidden" style="background-color:rgb(241,241,241);">
		<li id="new-task">
			<img src="images/icons/fam/network.png" />
			<a href="javascript:void(0);" rel="bin/interface.php" title="端口管理">端口管理</a>
		</li>
		<li >
			<img src="images/icons/fam/privicons/bonding.gif" />
			<a href="javascript:void(0);" rel="bin/bond.php" title="链路聚合管理">链路聚合管理</a>
		</li>
		<li >
			<img src="images/icons/fam/privicons/vlan.png" />
			<a href="javascript:void(0);" rel="bin/vlan.php" title="VLAN管理">VLAN管理</a>
		</li>
		<li >
			<img src="images/icons/fam/privicons/spanningTree.png" />
			<a href="javascript:void(0);" rel="bin/spanningTree.php" title="生成树管理">生成树管理</a>
		</li>
		<li >
			<img src="images/icons/fam/privicons/route.png" />
			<a href="javascript:void(0);" rel="bin/rtable.php" title="路由管理">路由管理</a>
		</li>
		<li >
			<img src="images/icons/fam/privicons/snat.png" />
			<a href="javascript:void(0);" rel="bin/snat.php" title="SNAT管理">SNAT管理</a>
		</li>
		<li >
			<img src="images/icons/fam/privicons/apr.png" />
			<a href="javascript:void(0);" rel="bin/arptable.php" title="ARP管理">ARP管理</a>
		</li>
	</ul>
	<!-- network-manage end  -->
	
	<!-- Vserver-manage start 虚拟服务器管理   -->
	<ul id="vserver-manage" class="x-hidden" style="background-color:rgb(241,241,241);">
		<!--<li>
				<img src="images/s.gif" class="icon-no-group"/> 
			<img src="images/icons/fam/privicons/contentswitch.png" />
			<a href="javascript:void(0);" rel="bin/rule.php" title="策略规则">策略规则</a>
		</li>-->
		<li>
			<img src="images/icons/fam/privicons/vserver.png" />
			<a href="javascript:void(0);" rel="bin/vserver.php" title="虚拟服务器管理">虚拟服务器管理</a>
		</li>
		<li>
			<img src="images/icons/fam/privicons/pool.png" />
			<a href="javascript:void(0);" rel="bin/pool.php" title="应用池管理">应用池管理</a>
		</li>
		<li>
			<img src="images/icons/fam/privicons/healthcheck.png" />
			<a href="javascript:void(0);" rel="bin/healthcheck.php" title="健康检查管理">健康检查管理</a>
		</li>
	</ul>
	<!-- Vserver-manage end  -->
	
	<!-- PolicyRule-manage start 策略规则管理   -->
	<ul id="policyRule-manage" class="x-hidden" style="background-color:rgb(241,241,241);">
		<?php
		//	$funcs = $_COOKIE['funcs'];
		//	if ($funcs[2] == "Y" || $funcs[2] == "y") {
		?>
		<li>
			<img src="images/icons/fam/privicons/req_f.png" />
			<a href="javascript:void(0);" rel="bin/request_filter.php" \
							title="请求过滤管理">请求过滤管理</a>
		</li>
		<li>
			<img src="images/icons/fam/privicons/contentswitch.png" />
			<a href="javascript:void(0);" rel="bin/content_switch.php" \
							title="内容交换管理">内容交换管理</a>
		</li>
		<li>
			<img src="images/icons/fam/privicons/req_rew.png" />
			<a href="javascript:void(0);" rel="bin/request_rewrite.php" \
							title="请求改写管理">请求改写管理</a>
		</li>
		<li>
			<img src="images/icons/fam/privicons/res.png" />
			<a href="javascript:void(0);" rel="bin/response_rewrite.php" \
							title="响应改写管理">响应改写管理</a>
		</li>
		<?php
		//	}
		?>
	</ul>
	<!-- PolicyRule-manage end   -->
	

	
	<!-- system-diagnosis start 系统诊断   -->
	<ul id="system-diagnosis" class="x-hidden" style="background-color:rgb(241,241,241);">
		<li>
			<img src="images/icons/fam/privicons/history.png" />
			<a href="javascript:void(0);" rel="bin/log.php" title="日志管理">日志管理</a>
		</li>
		<li>
			<img src="images/icons/fam/privicons/alert.png" />
			<a href="javascript:void(0);" rel="bin/smtp.php" title="告警管理">告警管理</a>
		</li>
		<li>
			<img src="images/icons/fam/privicons/disaster2.png" />
			<a href="javascript:void(0);" rel="bin/diagnosis.php" title="故障诊断管理">故障诊断管理</a>
		</li>
	</ul>
	<!-- system-diagnosis end   -->
<script type="text/javascript">
initialization();
</script>
</body>
</html>
